package com.wtz.util.learn.stringutils;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Date: 2020/10/26
 * Company: www.dtstack.com
 *
 * @author tiezhu
 */
public class ReplaceDemo {
    private static final String[] NEED_QUOTE_TYPE = {"string", "timestamp", "varchar"};

    public static void main(String[] args) {
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        System.out.println(timestamp.getTime());
        System.out.println(new Date(timestamp.getTime()));
        System.out.println(new Time(timestamp.getTime()));

        List<String> temp = new ArrayList<>();

        Arrays.stream(NEED_QUOTE_TYPE).forEach(f -> temp.add(f.toUpperCase()));
        for(String item : temp) {
            System.out.println(item);
        }
    }

    private static String replaceWithOutQuotation(String strWithQuotation,
                                                  String needReplacedStr,
                                                  String replacedStr) {
        if (strWithQuotation.contains(needReplacedStr)) {
            int i = strWithQuotation.indexOf(needReplacedStr);
            char cOne = strWithQuotation.charAt(i - 1);
            char cTwo = strWithQuotation.charAt(i + needReplacedStr.length());
            if (cOne == '\'' && cTwo == '\'') {
                System.out.println("have ' and need to be ignored");
            }
        }
        return strWithQuotation;
    }

    private static boolean isQuoted(String str) {
        return false;
    }
}
